package com.sw.core.expopr.exception;

/**
 * @author:YF
 * @Dat:   2014年1月23日   下午2:53:16 
 * @version: v1.0
 * @Description : TODO
 */
public class BaseException extends RuntimeException {
	
	private String code;
	private String message;
	private String info;
	
	public BaseException(){
		super();
	}
	
	public BaseException(Throwable throwable){
		super(throwable);
		message = (new StringBuilder()).append('`').append(throwable.getMessage()).append('`').toString();
		info = throwable.getMessage();
	}
	
	public BaseException(String code){
		super(code);
		this.code = code;
		message = code;
		info = code;
	}
	
	
	public BaseException(String code,Throwable throwable){
		super(code,throwable);
		this.code = code;
		message = (new StringBuilder()).append('`').append(throwable.getMessage()).append('`').toString();
		info = throwable.getMessage();
	}
	
	public BaseException(String code,String[] params,String message){
		super(code);
		this.code = code;
		this.message = (new StringBuilder()).append(code).append(":").append(message).append(parseParams(params)).toString();
        info = message;
	}
	
	
    private String parseParams(String params[])
    {
        if(params == null)
            return "";
        StringBuilder sb = new StringBuilder();
        String arr$[] = params;
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; i$++)
        {
            String param = arr$[i$];
            sb.append(param).append("~");
        }

        return sb.toString();
    }
	
	/**
	 * @return the code
	 */
	public String getCode() {
		return code;
	}

	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @return the info
	 */
	public String getInfo() {
		return info;
	}


}
